package com.hhf.feiojjudgeservice.codesandbox.proxy;

import com.hhf.feiojjudgeservice.codesandbox.CodeSandbox;
import com.hhf.feiojjudgeservice.codesandbox.model.ExecuteCodeRequest;
import com.hhf.feiojjudgeservice.codesandbox.model.ExecuteCodeResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author hhf
 * @Date 2024/10/27
 * @Description 代码沙盒静态代理, 实现日志的记录
 */
@Slf4j
public class CodeSandboxProxy implements CodeSandbox {

    private final CodeSandbox codeSandbox;

    public CodeSandboxProxy(CodeSandbox codeSandbox) {
        this.codeSandbox = codeSandbox;
    }

    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {

        log.info("代理开启,正在记录日志...");
        ExecuteCodeResponse response = codeSandbox.executeCode(executeCodeRequest);
        log.info("方法执行完成,结束代理...");
        return response;
    }
}
